import { Component, Input } from '@angular/core';
import { TableWidthConfig } from '@devui';
import { JobOrderService } from 'src/app/@core/services/jobOrder/job-order.service';

@Component({
  selector: 'app-select-inspection-item',
  templateUrl: './select-inspection-item.component.html',
  styleUrls: ['./select-inspection-item.component.scss']
})
export class SelectInspectionItemComponent {
  @Input() data: any;
    isSelected = false;
    displayTableData: any[] = [];
    tableheight = '230px';
    selectData:any;
    searchName=''
    pager = {
      total: 20,
      pageIndex: 1,
      pageSize: 20
    };
    pageSizeOptions = [10, 20, 30, 50, 100];
    dataTableOptions = {
      columns: [
        {
          field:'radio',
          header:'选择',
          fieldType:'radio',
          fixedLeft:'0px'
        },
        {
          field: 'type',
          header: '质检项名称',
          fieldType: 'text'
        },
        {
          field: 'type',
          header: '质检项描述',
          fieldType: 'text'
        },
        {
          field: 'type',
          header: '质检单位',
          fieldType: 'text'
        }
      ]
    };
    tableWidthConfig: TableWidthConfig[] = [
      {
        field: 'radio',
        width: '50px'
      },
      {
        field: 'enabled',
        width: '150px'
      },
      {
        field: 'enabled',
        width: '150px'
      },
      {
        field: 'enabled',
        width: '150px'
      }
    ]
    constructor(private JobOrderService:JobOrderService) { }
    ngOnInit(): void {
     this.JobOrderService.GetPagedInspectionProject(this.searchName,this.pager.pageIndex,this.pager.pageSize).subscribe((res:any)=>{
      this.displayTableData = res.items
      this.pager.total = res.totalCount
     })
    }
    radio(event: any,rowItem:any){
      if(event.target.checked){
        this.isSelected = true;
        this.selectData = rowItem
      }
    }
    pageIndexChange($event: any) {
      this.pager.pageIndex=$event;
      this.JobOrderService.GetPagedInspectionProject(this.searchName,this.pager.pageIndex,this.pager.pageSize).subscribe((res:any)=>{
        this.displayTableData = res.items
        this.pager.total = res.totalCount
       })
    }//切换页码
    pageSizeChange($event: any){
      this.JobOrderService.GetPagedInspectionProject(this.searchName,this.pager.pageIndex,this.pager.pageSize).subscribe((res:any)=>{
        this.displayTableData = res.items
        this.pager.total = res.totalCount
       })
    }//改变每页显示数量
    search(){
      this.JobOrderService.GetPagedInspectionProject(this.searchName,this.pager.pageIndex,this.pager.pageSize).subscribe((res:any)=>{
        this.displayTableData = res.items
        this.pager.total = res.totalCount
       })
    }
    reset(){
      this.searchName = ''
      this.JobOrderService.GetPagedInspectionProject(this.searchName,this.pager.pageIndex,this.pager.pageSize).subscribe((res:any)=>{
        this.displayTableData = res.items
        this.pager.total = res.totalCount
       })
    }
}
